# 初始化学生列表，用于存储所有学生信息字典
students = []

def show_menu():
    """显示系统菜单"""
    print("======================")
    print("学生管理系统 V10.0")
    print("1.添加学生信息")
    print("2.删除学生信息")
    print("3.修改学生信息")
    print("4.查询所有学生信息")
    print("0.退出系统")
    print("======================")

def add_student():
    """添加学生信息"""
    name = input("请输入姓名：")
    gender = input("请输入性别：")
    phone = input("请输入手机号：")
    # 创建学生字典
    student = {"姓名": name, "性别": gender, "手机号": phone}
    students.append(student)
    print("添加成功！")

def delete_student():
    """删除学生信息"""
    index = int(input("请输入要删除学生的序号："))
    if 0 <= index < len(students):
        students.pop(index)
        print("删除成功！")
    else:
        print("序号无效，请重新输入！")

def modify_student():
    """修改学生信息"""
    if not students:
        print("学生信息表为空")
        return
    index = int(input("请输入待修改学生的序号："))
    if 0 <= index < len(students):
        name = input("请输入修改后的姓名：")
        gender = input("请输入修改后的性别：")
        phone = input("请输入修改后的手机号：")
        students[index] = {"姓名": name, "性别": gender, "手机号": phone}
        print("修改成功！")
    else:
        print("序号无效，请重新输入！")

def query_all_students():
    """查询所有学生信息"""
    if not students:
        print("学生信息表为空")
        return
    # 打印表头
    print("序号\t姓名\t性别\t手机号")
    for i, student in enumerate(students):
        print(f"{i}\t{student['姓名']}\t{student['性别']}\t{student['手机号']}")

def main():
    """主函数"""
    while True:
        show_menu()
        choice = input("请输入功能序号：")
        if choice == "1":
            add_student()
        elif choice == "2":
            delete_student()
        elif choice == "3":
            modify_student()
        elif choice == "4":
            query_all_students()
        elif choice == "0":
            print("退出系统")
            break
        else:
            print("输入有误，请重新输入！")

if __name__ == "__main__":
    main()

